
package physical_spaces.beans;

import Entity.DataFile;
import java.io.Serializable;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;
import login.beans.ConectionBean;
import physical_spaces.business.DataFileDataModel;
import physical_spaces.business.PhysicalSpaceBusiness;

/**
 *
 * @author JuanFelipe
 */
@ManagedBean(name = "tablePhysical")
@ViewScoped
public class TablePhysicalSpaceBean  implements Serializable{
    private List<DataFile> dataFields ;
    private static final long serialVersionUID = 408L;
    DataFileDataModel mediumDataFileModel;
    public DataFile selecteddatafile;
    public String nombre;
    public String sizeDataFile;

    public DataFileDataModel getMediumDataFileModel() {
        return mediumDataFileModel;
    }

    public void setMediumDataFileModel(DataFileDataModel mediumDataFileModel) {
        this.mediumDataFileModel = mediumDataFileModel;
    }

    public DataFile getSelecteddatafile() {
        return selecteddatafile;
    }

    public void setSelecteddatafile(DataFile selecteddatafile) {
        this.selecteddatafile = selecteddatafile;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }


    public TablePhysicalSpaceBean(  ) {
        FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
        HttpSession session = (HttpSession) context.getExternalContext().getSession(false);
        ConectionBean conectionBean =(ConectionBean) session.getAttribute("conectionBean");
        
        dataFields = new ArrayList<>();
        chargeData( conectionBean.currentConnection );
        mediumDataFileModel = new DataFileDataModel(dataFields);

    }

    public DataFileDataModel getMediumTableSpaceModel() {
        return mediumDataFileModel;
    }   
    
    public List<DataFile> getDataFields() {
        return dataFields;
    }

    public void setDataFields(List<DataFile> dataFields) {
        this.dataFields = dataFields;
    }

    private void chargeData( Connection conn ) {
        PhysicalSpaceBusiness psb = new PhysicalSpaceBusiness( conn );
        dataFields = psb.getDataFields();
    }
    
    
    
}
